package p270jp;

import p243io.reactivex.exceptions.CompositeException;
import p244ip.Call;
import p244ip.Callback;
import p244ip.Response;
import p418pd.RxJavaPlugins;
import p436q6.StringMerger;
import p593wc.AbstractC6902j;
import p593wc.AbstractC6903n;
import p671zc.Disposable;

/* renamed from: jp.b */
/* loaded from: classes2.dex */
public final class CallEnqueueObservable<T> extends AbstractC6902j<Response<T>> {

    /* renamed from: a */
    public final Call<T> f18265a;

    /* compiled from: CallEnqueueObservable.java */
    /* renamed from: jp.b$a */
    /* loaded from: classes2.dex */
    public static final class C3979a<T> implements Disposable, Callback<T> {

        /* renamed from: a */
        public final Call<?> f18266a;

        /* renamed from: b */
        public final AbstractC6903n<? super Response<T>> f18267b;

        /* renamed from: c */
        public volatile boolean f18268c;

        /* renamed from: d */
        public boolean f18269d = false;

        public C3979a(Call<?> bVar, AbstractC6903n<? super Response<T>> nVar) {
            this.f18266a = bVar;
            this.f18267b = nVar;
        }

        @Override // p671zc.Disposable
        /* renamed from: a */
        public void mo78a() {
            this.f18268c = true;
            this.f18266a.cancel();
        }

        @Override // p244ip.Callback
        /* renamed from: b */
        public void mo4871b(Call<T> bVar, Response<T> zVar) {
            if (!this.f18268c) {
                try {
                    this.f18267b.mo305g(zVar);
                    if (!this.f18268c) {
                        this.f18269d = true;
                        this.f18267b.onComplete();
                    }
                } catch (Throwable th) {
                    StringMerger.m2841u(th);
                    if (this.f18269d) {
                        RxJavaPlugins.m3026b(th);
                    } else if (!this.f18268c) {
                        try {
                            this.f18267b.mo307b(th);
                        } catch (Throwable th2) {
                            StringMerger.m2841u(th2);
                            RxJavaPlugins.m3026b(new CompositeException(th, th2));
                        }
                    }
                }
            }
        }

        @Override // p244ip.Callback
        /* renamed from: c */
        public void mo4870c(Call<T> bVar, Throwable th) {
            if (!bVar.isCanceled()) {
                try {
                    this.f18267b.mo307b(th);
                } catch (Throwable th2) {
                    StringMerger.m2841u(th2);
                    RxJavaPlugins.m3026b(new CompositeException(th, th2));
                }
            }
        }

        @Override // p671zc.Disposable
        /* renamed from: e */
        public boolean mo77e() {
            return this.f18268c;
        }
    }

    public CallEnqueueObservable(Call<T> bVar) {
        this.f18265a = bVar;
    }

    @Override // p593wc.AbstractC6902j
    /* renamed from: r */
    public void mo983r(AbstractC6903n<? super Response<T>> nVar) {
        Call<T> clone = this.f18265a.mo12304clone();
        C3979a aVar = new C3979a(clone, nVar);
        nVar.mo306c(aVar);
        if (!aVar.f18268c) {
            clone.mo5105q0(aVar);
        }
    }
}
